package utils;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.content.ContextCompat;

import org.webrtc.PeerConnection;

import java.util.ArrayList;
import java.util.List;

public class WebRTCUtils {


    private WebRTCUtils () {

    }

    public static void requestPermissions(Context context, String[] requestPermissions, int requestPermissionCode) {
        if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA)
                == PackageManager.PERMISSION_DENIED) {
            androidx.core.app.ActivityCompat.requestPermissions((Activity) context, requestPermissions, requestPermissionCode);
        }
    }

    public static List<PeerConnection.IceServer> getInitIceServers() {
        List<String> urls = new ArrayList<>();
        urls.add("stun:stun.l.google.com:19302");
        urls.add("stun:stun1.l.google.com:19302");
        List<PeerConnection.IceServer> iceServers = new ArrayList<>();
        iceServers.add(PeerConnection.IceServer.builder(urls).createIceServer());
        return iceServers;
    }

}
